package com.taobao.txc.common.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.taobao.txc.common.b.b;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;

public class c
{
  private static final Cache<String, ConcurrentHashMap<String, String>> b = CacheBuilder.newBuilder().maximumSize(1000L).expireAfterWrite(300000L, TimeUnit.MILLISECONDS).softValues().build();
  private String c;
  Map<String, m> a = new HashMap();
  
  public c(String paramString)
  {
    this.c = paramString;
  }
  
  protected String a(String paramString1, String paramString2)
  {
    String str = System.getProperty(paramString2);
    if (StringUtils.isNotEmpty(str)) {
      return str;
    }
    if (StringUtils.isNotEmpty(paramString1))
    {
      str = (String)a(paramString1).get(paramString2);
      if (StringUtils.isNotEmpty(str)) {
        return str;
      }
    }
    return (String)a("global").get(paramString2);
  }
  
  public void a(String paramString1, String paramString2, m paramm)
  {
    String str = System.getProperty(paramString1);
    if (StringUtils.isNotEmpty(str))
    {
      paramm.a(str);
      return;
    }
    if (StringUtils.isNotEmpty(paramString2))
    {
      b(paramString2, paramString1, paramm);
      return;
    }
    b("global", paramString1, paramm);
  }
  
  private Map<String, String> a(String paramString)
  {
    if (StringUtils.isEmpty(paramString)) {
      return new ConcurrentHashMap();
    }
    String str = this.c + paramString;
    Map localMap = null;
    try
    {
      localMap = (Map)b.get(str, new d(this, str));
    }
    catch (ExecutionException localExecutionException) {}
    if (localMap == null) {
      throw new com.taobao.txc.common.b.c("unexpect", b.k);
    }
    return localMap;
  }
  
  private void b(String paramString1, String paramString2, m paramm)
  {
    if ((StringUtils.isEmpty(paramString1)) || (StringUtils.isEmpty(paramString2))) {
      return;
    }
    String str1 = this.c + paramString1;
    synchronized (this.a)
    {
      if (!this.a.containsKey(paramString2)) {
        this.a.put(paramString2, paramm);
      }
    }
    if ((paramm != null) && (i.b() != null)) {
      try
      {
        ??? = i.b().a(str1, "TXC_GROUP");
        if (??? != null)
        {
          StringTokenizer localStringTokenizer = new StringTokenizer((String)???, "\r\n");
          while (localStringTokenizer.hasMoreElements())
          {
            String str2 = localStringTokenizer.nextToken();
            int i = str2.indexOf('=');
            if (i <= 0) {
              throw new com.taobao.txc.common.b.c("invalid txc rules", b.j);
            }
            String str3 = str2.substring(0, i);
            String str4 = str2.substring(i + 1);
            if (str3.equals(paramString2)) {
              paramm.a(str4);
            }
          }
        }
      }
      catch (Exception localException) {}
    }
    i.a(str1, "TXC_GROUP", new e(this));
  }
}


/* Location:           C:\Users\ibm\Downloads\txc-yun-sample (1)\txc-yun-sample\lib\txc-client-2.0.72.jar
 * Qualified Name:     com.taobao.txc.common.config.c
 * JD-Core Version:    0.7.0.1
 */